import 'package:flutter/material.dart';
import '../widgets/form/DDSessionTitle.dart';
import '../widgets/form/DDEditField.dart';

// Create a Form Widget
class TestEditPage extends StatefulWidget {
  @override
  TestEditPageState createState() {
    return TestEditPageState();
  }
}

class TestEditPageState extends State<TestEditPage> {
  final _formKey = GlobalKey<FormState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('车贷信息'),
        centerTitle: true,
      ),
      body: new Form(
        key: _formKey,
        child: Card(
          margin: EdgeInsets.all(10.0),
          child: Padding(
            padding: EdgeInsets.all(10.0),
            child: ListView(
              children: <Widget>[
                new DDSessionTitle("借款人信息"),
                new DDEditField(
                  labelText: "姓名",
                  editField: TextFormField(
                    initialValue: "陈小生",
                    decoration: const InputDecoration(
                      border: const UnderlineInputBorder(),
                      hintText: '请输入姓名',
                      counterText: "",
                    ),
                    maxLength: 10,
                  ),
                  required: true,
                ),
                new DDEditField(
                  labelText: "性别",
                  editField: TextFormField(
                    initialValue: "男",
                    decoration: const InputDecoration(
                      border: const UnderlineInputBorder(),
                      hintText: '请输入性别',
                      counterText: "",
                    ),
                    maxLength: 1,
                  ),
                  required: true,
                ),
                new DDEditField(
                  labelText: "出生日期",
                  editField: TextFormField(
                    initialValue: "1981-05-03",
                    decoration: const InputDecoration(
                      border: const UnderlineInputBorder(),
                      hintText: '请输入出生日期',
                      counterText: "",
                    ),
                    maxLength: 10,
                  ),
                  required: true,
                ),
                new DDEditField(
                  labelText: "身份证号码",
                  editField: TextFormField(
                    initialValue: "350626201210304426",
                    decoration: const InputDecoration(
                      border: const UnderlineInputBorder(),
                      hintText: '请输入身份证号码',
                    ),
                    maxLength: 18,
                    keyboardType: TextInputType.phone,
                  ),
                  required: true,
                ),
                new DDEditField(
                  labelText: "地址",
                  editField: TextFormField(
                    initialValue: "XX省XX市XX县XX镇XX村XX号",
                    decoration: const InputDecoration(
                      border: const UnderlineInputBorder(),
                      hintText: '请输入地址',
                    ),
                    maxLength: 50,
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
